var app = require('express')()
var http = require('http').createServer(app)
var io = require('socket.io')(http)

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html')
})

io.on('connection', socket => {
  // 客户端返回什么内容回来，我就回复什么消息
  socket.on('message', value => {
    // 原样返回
    socket.emit('message', value)
  })
})

http.listen(3000, () => {
  console.log('listening on *:3000')
})
